﻿using Edu.Common;
using System.IO;

namespace MainApp.Utils
{
    class AppConfig : JsonConfigBase
    {
        /// <summary>
        /// 获取或设置是否自动启动程序
        /// </summary>
        public bool AutoRun
        {
            get => Get("Base", nameof(AutoRun), true);
            set => Set("Base", nameof(AutoRun), value);
        }
        /// <summary>
        /// 获取或设置程序是否遮挡桌面
        /// </summary>
        public bool CoverDesktop
        {
            get => Get("Base", nameof(CoverDesktop), true);
            set => Set("Base", nameof(CoverDesktop), value);
        }
        /// <summary>
        /// 获取或设置是否始终强制置顶显示ppt演示窗口
        /// </summary>
        public bool ForegroundSlideViewWindow
        {
            get => Get("Base", nameof(ForegroundSlideViewWindow), false);
            set => Set("Base", nameof(ForegroundSlideViewWindow), value);
        }
        /// <summary>
        /// 获取或设置是否自动关闭非指定打开的ppt文件
        /// </summary>
        public bool CloseOtherPptFile
        {
            get => Get("Base", nameof(CloseOtherPptFile), true);
            set => Set("Base", nameof(CloseOtherPptFile), value);
        }
        /// <summary>
        /// 获取或设置安全密钥
        /// </summary>
        public string SecrityKey
        {
            get => Get("Base", nameof(SecrityKey), CryptoHelper.GetMd532StrUpper("123456"));
            set => Set("Base", nameof(SecrityKey), value);
        }
        static AppConfig()
        {
            Current = new AppConfig();
        }
        /// <summary>
        /// 获取或设置启动程序时要运行的ppt文件
        /// </summary>
        public string RunFilePath
        {
            get => Get("Base", nameof(RunFilePath), string.Empty);
            set => Set("Base", nameof(RunFilePath), value);
        }

        /// <summary>
        /// 获取最大空闲时间，分钟
        /// </summary>
        public double MaxFreeTimes
        {
            get => Get("Base", nameof(MaxFreeTimes), 10d);
            set => Set("Base", nameof(MaxFreeTimes), value);
        }
        protected AppConfig() : base(Path.Combine(AppInfo.APP_PROFILE_PATH, "app-config.json"))
        {
        }
        public static AppConfig Current { get; }
    }
}
